import xlrd
import xlwt
from xlutils.copy import copy
import os

# 创建一个workbook 设置编码
workbook = xlwt.Workbook(encoding = 'utf-8')

# 创建一个worksheet
worksheet = workbook.add_sheet('结果比较表')

# 写入excel
# 参数对应 行, 列, 值
worksheet.write(0,0, label = '原图所对应昆虫名')
worksheet.write(0,1, label = '百度')
worksheet.write(0,2, label = '西安网极网络科技有限公司')
worksheet.write(0,3, label = '北京艾特阿尔法科技有限责任公司')

animal={}

#baidu
imgs = os.listdir("H:\学习\研究生\动物识别\\test-baidu")
imgNum = len(imgs)
count=1
for i in range (imgNum):
    originalName=imgs[i].split("-")[0]
    baiduName=imgs[i].split("-")[1].split(".")[0]
    worksheet.write(count, 0, originalName)
    worksheet.write(count, 1, baiduName)
    animal[originalName] = count
    count=count+1


#xian
imgs = os.listdir("H:\学习\研究生\动物识别\\test-xian")
imgNum = len(imgs)

for i in range (imgNum):

    originalName=imgs[i].split("-")[0]
    count = animal[originalName]
    xianName=imgs[i].split("-")[1].split(".")[0]
    worksheet.write(count, 2, xianName)

#beijing
imgs = os.listdir("H:\学习\研究生\动物识别\\test-beijing")
imgNum = len(imgs)

for i in range (imgNum):

    originalName=imgs[i].split("-")[0]
    count = animal[originalName]

    beijingName=imgs[i].split("-")[1].split(".")[0]
    worksheet.write(count, 3, beijingName)

workbook.save('结果比较表.xls')